﻿using System.Data;
using DTO;

namespace DAO
{
    public class NhanVien_Dao 
    {
        private readonly BaseOperationImplement<NhanVien_Dto> _operationImp = new BaseOperationImplement<NhanVien_Dto>();

        public DataTable GetAllObject()
        {
            return _operationImp.GetAllObject("NhanVien");
        }

        public int AddObject(NhanVien_Dto obj)
        {
            return _operationImp.AddObject("insNhanVien", CommandType.StoredProcedure,
                                           "@manv", obj.MaNV, "@tennv", obj.TenNV, "@diachi", obj.DiaChi, "@gioitinh",
                                           obj.GioiTinh, "@ngaysinh", obj.NgaySinh, "@maque", obj.MaQue, "@sdt", obj.SDT);
        }

        public int EditObject(string id, NhanVien_Dto newObj)
        {
            return _operationImp.EditObject("updateNhanVien", CommandType.StoredProcedure,
                                            "@manv", id, "@tennv", newObj.TenNV, "@diachi", newObj.DiaChi, "@gioitinh",
                                            newObj.GioiTinh, "@ngaysinh", newObj.NgaySinh, "@maque", newObj.MaQue,
                                            "@sdt", newObj.SDT);
        }

        public int DeleteObject(string id)
        {
            return _operationImp.DeleteObject("delNhanVien", CommandType.StoredProcedure, "@id", id);
        }


        public int AutoIncrementIdObject()
        {
            return _operationImp.AutoIncrementIdObject("NhanVien", "MaNV");
        }
    }
}